import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../routes/routes.dart';
import '../../../services/user_service.dart';
import '../../../utils/color.dart';

class MinenavigationBottom extends StatelessWidget {
  final UserService service;

  const MinenavigationBottom(this.service, {super.key});

  @override
  Widget build(BuildContext context) {
    void onCLick(int index) async {
      switch (index) {
        case 1: //兑换会员
          Get.toNamed(Routes.exchangevippage);
          break;
        case 2: //邀请码
          Get.toNamed(Routes.invitecodepage);
          break;
        case 3: //设置
          Get.toNamed(Routes.settingpage);
          break;
      }
    }

    return Container(
      margin: EdgeInsets.only(left: 16.w, right: 16.w),
      padding:
          EdgeInsets.only(top: 16.w, bottom: 16.w, left: 16.w, right: 16.w),
      decoration: BoxDecoration(
        color: COLOR.hexColor('#ffffff'),
        borderRadius: BorderRadius.circular(6.0),
      ),
      width: double.maxFinite,
      height: 168.w,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Container(
            child: Text(
              '更多服务',
              style: TextStyle(
                fontSize: 14.sp,
                color: COLOR.hexColor('#666666'),
                fontWeight: FontWeight.w600,
              ),
            ),
          ),
          Padding(padding: EdgeInsets.only(top: 10.w)),
          Expanded(
            child: InkWell(
              onTap: () => onCLick(1),
              child: _buldContent(
                  "assets/mine/img_mine_tab_changevip.png", "兑换会员", "填写兑换码"),
            ),
          ),
          Padding(padding: EdgeInsets.only(top: 10.w)),
          Expanded(
            child: InkWell(
              onTap: () => onCLick(2),
              child: _buldContent(
                  "assets/mine/img_mine_tab_invitecode.png", "邀请码", ""),
            ),
          ),
          Padding(padding: EdgeInsets.only(top: 10.w)),
          Expanded(
            child: InkWell(
              onTap: () => onCLick(3),
              child: _buldContent(
                  "assets/mine/img_mine_tab_setting_tips.png", "设置", ""),
            ),
          ),
        ],
      ),
    );
  }

  Widget _buldContent(String imgSource, String title, String desc) {
    return Flex(
      direction: Axis.horizontal,
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Expanded(
          child: Flex(
            direction: Axis.horizontal,
            children: [
              Image.asset(
                imgSource,
                width: 14.w,
                height: 14.w,
              ),
              Padding(padding: EdgeInsets.only(left: 3.w)),
              Text(
                title,
                style: TextStyle(
                  fontSize: 12.sp,
                  color: COLOR.hexColor("#999999"),
                  fontWeight: FontWeight.w600,
                ),
              ),
            ],
          ),
        ),
        Text(
          desc,
          style: TextStyle(
            fontSize: 12.sp,
            color: COLOR.hexColor('#999999'),
            fontWeight: FontWeight.w600,
          ),
        ),
        Padding(padding: EdgeInsets.only(right: 4.w)),
        Image.asset(
          "assets/mine/img_hide_apps_more.png",
          width: 8.w,
          height: 12.w,
        ),
      ],
    );
  }
}
